package com.yunbao.hujin.mymvpcommon.mvp.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * 所有Presenter的基类，并不强制实现这些方法，有需要在重写  on 2017/12/8.
 */

public class BasePresenter<V extends BaseView> {

    private V mView;     //V层引用

    /**
     * Presenter被创建后调用
     * @param saveBundle 被意外销毁后重建后的Bundle
     */
    public void onCreatePresenter(@Nullable Bundle saveBundle) {
        Log.e("perfect-mvp","P onCreatePersenter = ");
    }

    /**
     * 绑定V层
     */
    public void onAttachView(V view) {
        this.mView = view;
        Log.e("perfect-mvp","P onResume");
    }

    /**
     * 解除绑定V层
     */
    public void onDetachView() {
        mView = null;
        Log.e("perfect-mvp","P onDetachMvpView = ");
    }

    /**
     * 获取V层
     * @return 返回当前MvpView
     */
    public V getmMvpView() {
        return mView;
    }

    /**
     * Presenter被销毁时调用
     */
    public void onDestroyPresenter() {
        Log.e("perfect-mvp","P onDestroy = ");
    }

    /**
     * 在Presenter意外销毁的时候被调用，它的调用时机和Activity、Fragment、View中的onSaveInstanceState
     * 时机相同
     *
     * @param outState
     */
    public void onSaveInstanceState(Bundle outState) {
        Log.e("perfect-mvp","P onSaveInstanceState = ");
    }


}
